package com.qys.livesMall.event.listener;

import com.qys.livesMall.shortVideo.event.ShortVideoAddEvent;
import com.qys.livesMall.shortVideo.model.dto.ShortVideoEventDTO;
import com.qys.livesMall.shortVideo.service.IH2ShortVideoService;
import lombok.RequiredArgsConstructor;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;

/**
 * Created by IntelliJ IDEA.
 * User: dp
 * Date: 2023/05/09
 * Time: 13:56
 * DESCRIPTION:
 */
@RequiredArgsConstructor
public class ShortVideoListener {

    private final IH2ShortVideoService shortVideoService;

    @Async
    @Order
    @EventListener(ShortVideoAddEvent.class)
    public void saveBalanceLog(ShortVideoAddEvent event) {
        ShortVideoEventDTO dto = (ShortVideoEventDTO) event.getSource();
        shortVideoService.incrementVideo(dto);
    }
}
